package hk.m4s.lr.repair.test.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;
import java.util.Map;

import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.NoticeModel;
import hk.m4s.lr.repair.test.ui.user.UserNoticeActivity;

/**
 * 
 * @author
 * 
 */
public class UserDeviceAdapter extends BaseAdapter {
	private Context context;
	public List<Map> items;
	public UserDeviceAdapter(Context context,
							 List<Map> items) {
		this.context = context;
		this.items = items;
	}

	public int getCount() {
		return items.size();
	}

	public Object getItem(int position) {
		return getView(position, null, null);
	}

	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder=null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.list_item_user_device_text, null);
			 holder = new ViewHolder();
			holder.tvTitle = (TextView) convertView
					.findViewById(R.id.notice_title);
			holder.tvDay = (TextView) convertView.findViewById(R.id.notice_day);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (position >= items.size()) {
			return convertView;
		}
		final Map item = items.get(position);
		// 标题

		holder.tvTitle.setText(item.get("name").toString()+":");
		// 年月日

		holder.tvDay.setText(item.get("content").toString());
		// 小时分钟
		return convertView;
	}

	private class ViewHolder {
		TextView tvTitle;
		TextView tvDay;
	}
}
